package engine.step;

import engine.GameEngine;
import engine.data.Player;
import engine.data.Technology;

public final class CheckTechnologyStep extends Step {

	private static Step step;

	public static synchronized Step getStep() {
		if (step == null)
			step = new CheckTechnologyStep();
		return step;
	}

	public Step execute() {
		Player currPlayer = GameEngine.currPlayer;
		if (currPlayer.knowledgePoints >= currPlayer.getMaxRP(currPlayer.technology)) {
			currPlayer.knowledgePoints = 0;
			if (currPlayer.technology != Technology.NONE)
				currPlayer.technologies.add(new Byte(currPlayer.technology));
			currPlayer.controller.onNextTechnology();
			if (currPlayer.type != Player.HUMAN)
				return BeginTurnProcessStep.getStep();
		} else
			return BeginTurnProcessStep.getStep();
		return null;
	}
}
